package jedai.domain.security;

/*
 * Jedai Networking Framework - http://jedai.googlecode.com
 * 
 * Copyright (c) 2006-2009 by respective authors (see below). All rights reserved.
 * 
 * This library is free software; you can redistribute it and/or modify it under the 
 * terms of the GNU Lesser General Public License as published by the Free Software 
 * Foundation; either version 2.1 of the License, or (at your option) any later 
 * version. 
 * 
 * This library is distributed in the hope that it will be useful, but WITHOUT ANY 
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License along 
 * with this library; if not, write to the Free Software Foundation, Inc., 
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
 */

import javax.persistence.Column;
import javax.persistence.Embeddable;

/**
 * AuthoritiesId generated by hbm2java
 */
@Embeddable
public class AuthoritiesId implements java.io.Serializable {

	private String username;
	private String authority;

	public AuthoritiesId() {
	}

	public AuthoritiesId(String username, String authority) {
		this.username = username;
		this.authority = authority;
	}

	@Column(name = "username", nullable = false, length = 50)
	public String getUsername() {
		return this.username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	@Column(name = "authority", nullable = false, length = 50)
	public String getAuthority() {
		return this.authority;
	}

	public void setAuthority(String authority) {
		this.authority = authority;
	}

	public boolean equals(Object other) {
		if ((this == other))
			return true;
		if ((other == null))
			return false;
		if (!(other instanceof AuthoritiesId))
			return false;
		AuthoritiesId castOther = (AuthoritiesId) other;

		return ((this.getUsername() == castOther.getUsername()) || (this
				.getUsername() != null
				&& castOther.getUsername() != null && this.getUsername()
				.equals(castOther.getUsername())))
				&& ((this.getAuthority() == castOther.getAuthority()) || (this
						.getAuthority() != null
						&& castOther.getAuthority() != null && this
						.getAuthority().equals(castOther.getAuthority())));
	}

	public int hashCode() {
		int result = 17;

		result = 37 * result
				+ (getUsername() == null ? 0 : this.getUsername().hashCode());
		result = 37 * result
				+ (getAuthority() == null ? 0 : this.getAuthority().hashCode());
		return result;
	}

}
